///MyShortKey.js
///版本:1.0
///Editor:陈峰展(HandMU)
///免费使用，请保留以上个人版权

//构建常用函数

//返回页面顶部，模拟#链接
function GoToTopSharp()
{
	window.location.href = "#";
}

//返回页面顶部，使用scroll定位
function GoToTopScroll()
{
	window.scroll(0,0);
}

//返回页面顶部，带滚动效果
function GoToTopRoll() 
{ 
	var x1 = x2 = x3 = 0; 
	var y1 = y2 = y3 = 0; 
	if (document.documentElement) 
	{
		x1 = document.documentElement.scrollLeft || 0;
  		y1 = document.documentElement.scrollTop || 0;
 	} 
 	if (document.body) 
 	{
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
 	} 
 	x3 = window.scrollX || 0;
	y3 = window.scrollY || 0;
	var x = Math.max(x1, Math.max(x2, x3));
	var y = Math.max(y1, Math.max(y2, y3));
	window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
	if (x > 0 || y > 0) 
	{
		window.setTimeout("GoToTopRoll()", 25);
	}
}
 
//获取页面宽度、高度
function GetHeight()
{
	var ds = document.documentElement.scrollHeight;
	var bs = document.body.scrollHeight;
	var h = ds > bs?ds:bs;
	return h;
}

function GetKeyCode(event)
{
	//var ex = event || window.event;
	//var keycode = e.which;
	//var keycodes = ex.charCode || ex.keyCode;
	//return keycodes;
	var currKey=0,e=event ? event : (window.event ? window.event : null);
	currKey=e.keyCode||e.which||e.charCode;
 　　var keyName = String.fromCharCode(currKey);
 	//alert("按键码: " + currKey + " 字符: " + keyName);
 	//currKey = "ABC";
 	//return currKey;
}

function IsEditing()
{
	var arE = false;
	if(document.activeElement.type)
	{
		arE = true;
	}
	return arE;
}

function GetKeyCode2(e)
{
	//var ex = event || window.event;
	//var keycode = e.which;
	//var keycodes = ex.charCode || ex.keyCode;
	//return keycodes;
	if(IsEditing())
	{
		return;
	}
	var currKey=0,e=e ? e : (window.event ? window.event : arguments[0]);
	currKey=e.keyCode||e.which||es.charCode;
 　　var keyName = String.fromCharCode(currKey);
 	//alert("按键码: " + currKey + " 字符: " + keyName);
 	//currKey = "ABC";
 	return currKey;
}

//跳转至页面底部
function GoToRootScroll()
{
	window.scroll(0,GetHeight());
}
